package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.ScenicReviews;
import cn.wolfcode.luowowo.article.mapper.ScenicReviewsMapper;
import cn.wolfcode.luowowo.article.query.ScenicReviewsQuery;
import cn.wolfcode.luowowo.article.service.IScenicReviewsService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Author Riven
 * @Date 19/12/24 21:39
 */
@Service
public class ScenicReviewsServiceImpl implements IScenicReviewsService {

    @Autowired
    private ScenicReviewsMapper scenicReviewsMapper;

    @Override
    public PageInfo queryForList(ScenicReviewsQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        return new PageInfo(scenicReviewsMapper.queryForList(qo));
    }
    @Override
    public List<ScenicReviews> listTop5() {
        return scenicReviewsMapper.selectTop5();
    }
    @Override
    public List<ScenicReviews> listHot10() {
        return scenicReviewsMapper.selectHot10();
    }

    /**
     * 根据主键ID查询景点
     *
     * @param id 景点ID
     * @return
     */
    @Override
    public ScenicReviews getById(Long id) {
        return scenicReviewsMapper.selectByPrimaryKey(id);
    }

    /**
     * 查询内部景点
     * @param id
     * @return
     */
    @Override
    public List<ScenicReviews> selectSonById(Long id) {
        return scenicReviewsMapper.getByParentId(id);
    }

    /**
     * 查所有景点
     *
     * @param id
     */
    @Override
    public ScenicReviews selectByScenic(Long id) {
        return scenicReviewsMapper.selectByScenic(id);
    }

}
